package com.example.demospringsecurity.test;

import com.example.demospringsecurity.security.UserDetailsServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class CodeValidProvider extends DaoAuthenticationProvider {


    public CodeValidProvider(MyPasswordEncoder myPasswordEncoder,UserDetailsServiceImpl userDetailsService) {
        setPasswordEncoder(myPasswordEncoder);
        this.setUserDetailsService(userDetailsService);
    }

    @Override
    protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
        //实现图形验证码功能
        log.info("实现图形验证码功能");

        super.additionalAuthenticationChecks(userDetails, authentication);
    }
}
